package com.hnair;

import java.util.Date;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.hnair.ffp.api.ews.member.MemberApi;
import com.hnair.ffp.api.ews.member.request.LoginRequest;
import com.hnair.ffp.api.ews.member.request.QuickRegisterRequest;
import com.hnair.ffp.api.ews.member.response.LoginResponse;
import com.hnair.ffp.api.ews.member.response.QuickRegisterResponse;

public class OdsConsumer {

	public OdsConsumer() {
	}

	@SuppressWarnings("unchecked")
	private static <T> T getApiService(Class<T> t, String beanName) {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] { "dubbo-consumer.xml" });
		context.start();
		T api = (T) context.getBean(beanName); // get service invocation proxy
		return api;
	}

	public static void testLogin() {
		MemberApi api = getApiService(MemberApi.class, "ewsMemberApi");
		LoginRequest request = new LoginRequest();
		request.setLoginId("5000000097");
		request.setPwd("123456");
		LoginResponse res = api.login(request);
		System.out.println(JSONUtils.toJSONString(res));
	}

	public static void testQuickRegister() {
		QuickRegisterRequest request = new QuickRegisterRequest();
		request.setBirthday("");
		request.setCity("成都");
		request.setEmail("3221428170@qq.com");
		request.setEmailStatus("未验证");
		request.setEnrollChannel("海航国内官网");
		request.setEnrollChannelType("网站");
		request.setFid("");
		request.setFirstNameEn("casf");
		request.setFirstNameZh("工");
		request.setGender("男");
		request.setId("312424333333423");
		request.setLanguage("简体中文");
		request.setLastNameEn("adsf");
		request.setLastNameZh("在");
		request.setMobile("18224234342");
		request.setMobileStatus("已验证");
		request.setNationality("CN");
		request.setOther("1213123");
		request.setOtherIdType("回乡证");
		request.setPass("12312312333333");
		request.setPassword("123456");
		MemberApi api = getApiService(MemberApi.class, "ewsMemberApi");
		QuickRegisterResponse res = api.quickRegister(request);
		System.out.println(JSONUtils.toJSONString(res));
	}
}
